package cn.flying.financial.ccs.process.productinfo;

import java.util.ArrayList;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import cn.flying.financial.common.enums.PurposeEnum;
import cn.flying.financial.common.enums.RepaymentEnum;
import cn.flying.financial.ccs.process.productinfo.bo.LoanTermInfo;
import cn.flying.financial.ccs.process.productinfo.bo.LoanUseInfo;
import cn.flying.financial.ccs.process.productinfo.bo.ProductInfoReq;
import cn.flying.financial.ccs.process.productinfo.bo.ProductInfoResp;

/**
 *  产品信息服务
 * @author: lvyong
 * @date: 2023年01月29日 14:32
 * @version: 1.0
 */
@Service
public class ProductInfoProcess {
    private Logger logger = LoggerFactory.getLogger(this.getClass());

    public List<ProductInfoResp> getRepaymentMethod(ProductInfoReq req) {
        List<ProductInfoResp> respList = new ArrayList<>();
        RepaymentEnum[] enums = RepaymentEnum.values();
        for (RepaymentEnum repaymentEnum : enums) {
            ProductInfoResp resp = new ProductInfoResp();
            resp.setRepayId(repaymentEnum.getCode());
            resp.setRepayName(repaymentEnum.getDesc());

            List<LoanTermInfo> termInfos = new ArrayList<>();
            LoanTermInfo termInfo = new LoanTermInfo();
            termInfo.setLoanTerm(6);
            termInfos.add(termInfo);

            termInfo = new LoanTermInfo();
            termInfo.setLoanTerm(12);
            termInfos.add(termInfo);

            termInfo = new LoanTermInfo();
            termInfo.setLoanTerm(24);
            termInfos.add(termInfo);

            termInfo = new LoanTermInfo();
            termInfo.setLoanTerm(36);
            termInfos.add(termInfo);

            resp.setTermInfos(termInfos);

            List<LoanUseInfo> useInfos = new ArrayList<>();
            LoanUseInfo useInfo = new LoanUseInfo();
            useInfo.setPurposeId(PurposeEnum.U01.getCode());
            useInfo.setPurposeName(PurposeEnum.U01.getDesc());
            useInfos.add(useInfo);

            useInfo = new LoanUseInfo();
            useInfo.setPurposeId(PurposeEnum.U02.getCode());
            useInfo.setPurposeName(PurposeEnum.U02.getDesc());
            useInfos.add(useInfo);

            useInfo = new LoanUseInfo();
            useInfo.setPurposeId(PurposeEnum.U03.getCode());
            useInfo.setPurposeName(PurposeEnum.U03.getDesc());
            useInfos.add(useInfo);

            resp.setUseInfos(useInfos);

            respList.add(resp);
        }

        return respList;
    }
}
